<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org" >
<head th:replace="~{common/import :: tophead}">
    <title>Blogs</title>
</head>
<body>
<nav th:fragment="nav" class="navbar navbar-default">
    <div class="container-fluid">
        <div class="navbar-header">
            <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
                <span class="sr-only">Blogs</span>
            </button>
            <a class="navbar-brand" th:href="@{/}">Blogs</a>
        </div>
        <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
            <form class="navbar-form navbar-left">
                <div class="form-group">
                    <input type="text" class="form-control" placeholder="搜索Blogs">
                </div>
                <button type="submit" class="btn btn-default">搜索</button>
            </form>
            <ul class="nav navbar-nav navbar-right">
                <li th:if="${session.user != null}">
                    <a th:href="@{/publish}">发表Blog</a>
                </li>
                <li th:if="${session.user == null}">
                    <a type="button" data-toggle="modal" data-target="#loginModal" style="cursor:pointer;">登录</a>
                </li>
                <li th:if="${session.user != null}" class="dropdown">
<!--                    <img th:src="${session.user.avatar_url}" width="8%">-->
                    <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false" th:text="${session.user.name}">我<span class="caret"></span></a>
                    <ul class="dropdown-menu">
                        <li><a th:href="@{/manger/blogs?page=1}">我的Blogs</a></li>
                        <li><a th:href="@{/manger/replies}">最新回复</a></li>
                        <li><a href="#">个人资料</a></li>
                        <li><a th:href="@{/logout}">退出登录</a></li>
                    </ul>
                </li>
            </ul>
        </div>
    </div>

    <div class="modal fade" id="loginModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                        &times;
                    </button>
                    <h4 class="modal-title" id="loginModalLabel">
                        请选择快捷登录方式！
                    </h4>
                </div>
                <div class="modal-body" style="text-align: center">
                    <div class="row loginModelRow">
                        <img th:src="@{/images/github.svg}" style="width: 5%">
                        <a th:href="@{https://github.com/login/oauth/authorize?client_id=c2fd17e523182ce1fbd9&redirect_uri=http://localhost:8080/githubCallback&scope=user&state=1}">GitHub登录</a>
                    </div>
                    <div class=" row loginModelRow">
                        <img th:src="@{/images/gitee.svg}" style="width: 5%">
                        <a th:href="@{https://gitee.com/oauth/authorize?client_id=9ec64a0854dccc034e8a9ec8fd1cfcf5bf7f8a0e7ce605db907414e917f19762&redirect_uri=http://localhost:8080/giteeCallback&response_type=code&scope=user_info&state=1}">Gitee登录</a>
                    </div>
                </div>
            </div><!-- /.modal-content -->
        </div><!-- /.modal -->
    </div>
</nav>
</body>
</html>